<template>
	<view class="container">
		<view class="user">
			<view class="u-box">
				<image :src="$img_base_url(info.avatar)" mode="aspectFill"></image>
				<view class="info">
					<view class="name">
						{{info.nickname}}
					</view>
					<text>ID:{{info.id}}</text>
				</view>
			</view>
			<!-- <image @click="makePhoneCall(item.mobile)" :src="$img_path('/pagesRegion/1.png')" mode="widthFix"></image> -->
		</view>
		<view class="user">
			<view class="u-box data-box">
				<view class="i">
					<view class="num">
						{{info.children_count}}
					</view>
					<text>总数用户</text>
				</view>
				<view class="i">
					<view class="num">
						{{info.order_num}}
					</view>
					<text>订单总数</text>
				</view>
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.order_price}}
					</view>
					<text>订单总金额</text>
				</view>
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.total_price}}
					</view>
					<text>总佣金</text>
				</view>
			</view>
		</view>


		<view class="list">
			<view v-for="item,index in info.children" @click="toDetail(item)" class="item">
				<view class="left">
					<image :src="$img_base_url(item.avatar)" mode="aspectFill"></image>
					<view class="info">
						<view class="name">
							{{item.nickname}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as api from '@/utils/api/index.js'
	export default {
		data() {
			return {
				id: '',
				info: {}
			};
		},
		onLoad(e) {
			this.id = e.id
			this.getAgentDetails()
		},
		methods: {
			makePhoneCall(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber,
				});
			},
			async getAgentDetails() {
				const {
					code,
					data
				} = await api.getAgentDetails({
					user_id: this.id
				})
				if (code == 1) {
					this.info = data
				}
			},
			toDetail(item){
				uni.navigateTo({
					url:`/pagesRegion/myUsers/detail?id=` + item.id
				})
			}
		},

	}
</script>

<style>
	page {
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
	.container {
		.user {
			padding: 0 22rpx;
			margin-top: 20rpx;
			box-sizing: border-box;

			.u-box {
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223, 223, 223, 0.56);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				border: 2rpx solid #EEEEEE;
				padding: 24rpx 26rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;

				&>image {
					width: 88rpx;
					height: 88rpx;
					border-radius: 50%;
				}

				.info {
					padding-left: 20rpx;

					.name {
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
						line-height: 40rpx;
					}

					&>text {
						font-weight: 400;
						font-size: 24rpx;
						color: #818181;
						line-height: 34rpx;
						margin-top: 4rpx;
					}
				}
			}

			.data-box {
				padding: 56rpx 26rpx;
				display: flex;
				justify-content: space-between;

				.i {
					display: flex;
					flex-direction: column;
					align-items: center;

					.num {
						font-weight: bold;
						font-size: 40rpx;
						color: #000000;
						line-height: 56rpx;
					}

					text {
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-top: 4rpx;
					}
				}
			}

		}


		.list {
			padding-top: 18rpx;

			.item {
				padding: 20rpx 22rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #EEEEEE;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					display: flex;
					align-items: center;

					image {
						width: 88rpx;
						height: 88rpx;
						border-radius: 50%;
					}

					.info {
						padding-left: 20rpx;

						.name {
							font-weight: bold;
							font-size: 28rpx;
							color: #000000;
							line-height: 40rpx;
						}
					}
				}
			}
		}
	}
</style>